using Gateway.Common.Enums;
using Gateway.Common.Extensions;
using Gateway.Domain.EFCore.Configuration;
using Gateway.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Gateway.Domain.Configuration;

public class UploadFilesConfiguration : AggregateRootEntityConfiguration<UploadFiles>
{
    public override void Configure(EntityTypeBuilder<UploadFiles> builder)
    {
        builder.ToTable(t => t.HasComment("上传文件"));
        base.Configure(builder);
        builder.Property(x => x.FileNo).IsRequired().HasMaxLength(50).HasComment("文件号");
        builder.Property(x => x.Length).IsRequired().HasComment("文件大小");
        builder.Property(x => x.ExtInfo).HasColumnType("text").HasComment("文件扩展信息");
        builder.Property(x => x.Hash).HasMaxLength(200).HasComment("文件hash");
        builder.Property(x => x.Path).HasMaxLength(2000).HasComment("完整存储路径");
        builder.Property(x => x.OriginName).HasMaxLength(255).HasComment("原文件名");
        builder.Property(x => x.IsTemp).IsRequired().HasComment("是否是临时文件");
        builder.Property(x => x.StorageKey).IsRequired().HasMaxLength(100).HasComment("存储来源 local 本地 其他的归属为 oss 的 key");
    }
}